package cn.the.angry.tests;

import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JFrame;

import cn.the.angry.model.IDs;
import cn.the.angry.resourcemanager.ResourceManager;
import cn.the.angry.util.GraphicUtils;

public class BackgroundTest extends JFrame {
	
	private static final int WIDTH = 1100;
	private static final int HEIGHT = 600;
	
	
	public BackgroundTest(){
		super("BackgroundTest");
		this.setSize(new Dimension(WIDTH, HEIGHT));
		this.setTitle("SplashScreen");
		this.setResizable(false);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		getContentPane().add(getBackgroundCanvas());
		
	}
	
	private Canvas getBackgroundCanvas(){
		return new Canvas(){
			@Override
			public void paint(Graphics g)	{
				Graphics2D g2 = (Graphics2D)g;
//				g2.drawImage(ResourceManager.getImageClip(IDs.INGAME_GROUNDS_1, 5, 0, 340, 200),
//						     0, BackgroundTest.HEIGHT-200 
//						     , null);
				GraphicUtils.autoFill(g2, ResourceManager.getImageClip(IDs.INGAME_GROUNDS_1, 3, 0, 334, 200)
									   , 0, BackgroundTest.HEIGHT-200
									   , BackgroundTest.WIDTH, BackgroundTest.HEIGHT
									   , GraphicUtils.AUTOFILLHORIZONTAL);
				
				
				
				g2.dispose();
				
			}
		};
	}
	
	public static void main(String[] args) {
		BackgroundTest main = new BackgroundTest();
		main.setVisible(true);
	}
}
